#!/usr/bin/python
"""
/* solver.py - sudoku solver
 *
 * Copyright 2009
 * Authored by Chia-I Wu <olvaffe@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
""" 

import sys

class SudokuSolver:
    def __init__(self):
        self.puzzle = None

        self.row = [False] * 90
        self.col = [False] * 90
        self.grp = [False] * 90

        self.steps = []
        for i in xrange(9):
            self.steps.append([])

        self.scores = [-1] * 81

        self.tries = []
        for i in xrange(81):
            self.tries.append([])

        self.relatives = []
        for r in xrange(9):
            for c in xrange(9):
                tmp = []
                for x in xrange(9):
                    if x != c:
                        tmp.append(r * 9 + x)
                for y in xrange(9):
                    if y != r:
                        tmp.append(y * 9 + c)
                gr = (r / 3) * 3
                gc = (c / 3) * 3
                for y in xrange(gr, gr + 3):
                    for x in xrange(gc, gc + 3):
                        if y != r and x != c:
                            tmp.append(y * 9 + x)

                self.relatives.append(tmp)

    def _verify(self):
        print "verify"
        for r in xrange(9):
            for c in xrange(9):
                s = self.scores[r * 9 + c]
                if s == -1:
                    continue

                tmp = []
                for n in xrange(1, 10):
                    if not (self.row[r * 10 + n] or self.col[c * 10 + n] or self.grp[((r / 3) * 3 + (c / 3)) * 10 + n]):
                        tmp.append(n)

                if len(tmp) - 1 != s:
                    print "(%d, %d) has score %d, instead of %d" % (r, c, len(tmp) - 1, s)
                    return False

                
                old = self.tries[r * 9 + c][:]
                old.sort()
                if old != tmp:
                    print "(%d, %d) has tries", tmp, "instead of", old

                try:
                    self.steps[s].index(r * 9 + c)
                except:
                    print "(%d, %d) @ %d is not a step" % (r, c, s)
                    return False

        return True

    def _try(self, pos, n):
        positions = []
        for p in self.relatives[pos]:
            if self.scores[p] >= 0 and n in self.tries[p]:
                if len(self.tries[p]) == 1:
                    return False

                positions.append(p)

        r = pos / 9
        c = pos % 9
        self.row[r * 10 + n] = True
        self.col[c * 10 + n] = True
        self.grp[((r / 3) * 3 + (c / 3)) * 10 + n] = True

        self.puzzle[r][c] = n

        for p in positions:
            self.tries[p].remove(n)
            s = self.scores[p]
            self.scores[p] -= 1
            self.steps[s - 1][:0] = [p]
            self.steps[s].remove(p)

        return True

    def _undo(self, pos, n):
        r = pos / 9
        c = pos % 9
        self.row[r * 10 + n] = False
        self.col[c * 10 + n] = False
        self.grp[((r / 3) * 3 + (c / 3)) * 10 + n] = False

        self.puzzle[r][c] = 0

        for p in self.relatives[pos]:
            old_score = self.scores[p]
            if old_score == -1:
                continue

            if n not in self.tries[p]:
                y = p / 9
                x = p % 9
                if not (self.row[y * 10 + n] or self.col[x * 10 + n] or self.grp[((y / 3) * 3 + (x / 3)) * 10 + n]):
                    self.tries[p][:0] = [n]
                    self.scores[p] += 1
                    self.steps[old_score + 1][:0] = [p]
                    self.steps[old_score].remove(p)

    def _solve(self):
        pos = 81
        for score in xrange(9):
            if self.steps[score]:
                pos = self.steps[score].pop()
                break
        if pos >= 81:
            return True

        self.scores[pos] = -1

        for n in self.tries[pos]:
            if self._try(pos, n):
                if self._solve():
                    return True
                self._undo(pos, n)

        self.scores[pos] = score
        self.steps[score].append(pos)

        return False

    def _analyze(self):
        for i in xrange(90):
            self.row[i] = False
            self.col[i] = False
            self.grp[i] = False

        for r in xrange(9):
            for c in xrange(9):
                pos = r * 9 + c
                v = self.puzzle[r][c]
                if v:
                    if self.row[r * 10 + v] or self.col[c * 10 + v] or self.grp[((r / 3) * 3 + (c / 3)) * 10 + v]:
                        return False

                    self.row[r * 10 + v] = True
                    self.col[c * 10 + v] = True
                    self.grp[((r / 3) * 3 + (c / 3)) * 10 + v] = True

                    self.scores[pos] = -1

        for i in xrange(9):
            self.steps[i] = []

        for r in xrange(9):
            for c in xrange(9):
                pos = r * 9 + c
                v = self.puzzle[r][c]
                if not v:
                    tries = []
                    for n in xrange(1, 10):
                        if not (self.row[r * 10 + n] or self.col[c * 10 + n] or self.grp[((r / 3) * 3 + (c / 3)) * 10 + n]):
                            tries.append(n)

                    if not tries:
                        return False
                    
                    score = len(tries) - 1

                    self.tries[pos] = tries
                    self.scores[pos] = score
                    self.steps[score].append(pos)

        while (self.steps[0]):
            pos = self.steps[0].pop()
            r = pos / 9
            c = pos % 9

            v = self.tries[pos].pop()

            self.row[r * 10 + v] = True
            self.col[c * 10 + v] = True
            self.grp[((r / 3) * 3 + (c / 3)) * 10 + v] = True
            self.puzzle[r][c] = v

            self.scores[pos] = -1

            for p in self.relatives[pos]:
                s = self.scores[p]
                if s > 0 and v in self.tries[p]:
                    self.tries[p].remove(v)
                    self.scores[p] -= 1
                    self.steps[s - 1][:0] = [p]
                    self.steps[s].remove(p)

        return True

    def solve(self, puzzle):
        self.puzzle = puzzle

        if not self._analyze():
            return False

        return self._solve()

def parse_file():
    lines = sys.stdin.readlines()

    puzzles = []
    for l in lines:
        if (len(l) != 82):
            print "xxx"
            continue

        p = []
        for i in xrange(9):
            t = []
            for j in xrange(9):
                t.append(int(l[i * 9 + j]))
            p.append(t)
        puzzles.append(p)

    return puzzles

def main():
    solver = SudokuSolver()
    puzzles = parse_file()

    for p in puzzles:
        if (solver.solve(p)):
            pass
            for i in xrange(9):
                print p[i]
            print
        else:
            print "no solution"
        

if __name__ == "__main__":
    main()
